import { createRouter, createWebHistory } from "vue-router";

const router = createRouter({
	history: createWebHistory(import.meta.env.BASE_URL),
	routes: [
		{
			path: '/',
			name: 'home',
			meta: { title: '渔泡博客 | 首页' },
			component: () => import("@/views/HomeView.vue"),
		},
		{
			path: '/dynamic/:id(\\d+)',
			name: 'dynamic',
			meta: { title: '渔泡博客 | 文章详情页' },
			component: () => import("@/views/subdirectory/DetailsPage.vue"),
		},
		{
			path: '/sort',
			name: 'sort',
			meta: { title: '渔泡博客 | 分类' },
			component: () => import("@/views/SortView.vue"),
			children: [

			]
		},
		{
			path: '/tag',
			name: 'tag',
			meta: { title: '渔泡博客 | 标签' },
			component: () => import("@/views/LableView.vue"),
		},
		{
			path: '/archives',
			name: 'archives',
			meta: { title: '渔泡博客 | 归档' },
			component: () => import("@/views/ArchivesView.vue"),
		},
		{
			path: '/friend',
			name: 'friend',
			meta: { title: '渔泡博客 | 友链' },
			component: () => import("@/views/FriendView.vue"),
		},
		{
			path: '/about',
			name: 'about',
			meta: { title: '渔泡博客 | 关于' },
			component:() => import("@/views/AboutView.vue"),
		}, {
            path: '/404',
            name: '404',
            component: () => import("@/views/Notfound.vue"),
        },
        {
            path: '/:pathMatch(.*)',
            redirect: '/404'
        }
	],
});

router.beforeEach((to, from, next) => {
	window.document.title = to.meta.title as string
	next()
})

export default router;
